<?php
class Myblog_Form_UserLogin extends Zend_Form
{
public $formDecorators=array(
array('FormElements'),
array('Form'),
);
public $elementDecorators=array(
array('ViewHelper'),
array('Label'),
array('Errors'),
array('HtmlTag',array('dd'=>'span','dt'=>'span')),
);
public $usernameDecorators=array(
array('ViewHelper'),
array('Label'),
array('Errors'),
array('HtmlTag',array('dd'=>'span','dt'=>'span')),
);
public $checkDecorators=array(
array('ViewHelper'),
array('Label'),
array('HtmlTag',array('dt'=>'span','dd'=>'span','class'=>'chekbox'))
);
public $buttonDecorators=array(
array('ViewHelper'),
array('Label'),
array('HtmlTag',array('tag'=>'span','tag'=>'span'))
);
public $linkDecorators=array(
array('ViewHelper'),
array('Label'),

);
	public function init()
	{
	$this->setMethod('POST')
	->setAction('user/login')
	->setName('userslogin')
	->setAttrib('onsubmit','return checklogin()')
	->setDecorators($this->formDecorators);
	
	$this->addElements(array(
	$userlogin = new Zend_Form_Element_Text('login', array(
			'label'=>'Логин:',
			'required'=>'true',
            'autocomplete'=>'off',
			'size'=>'14',
		    'validators'=>array('NotEmpty'),
									array('NameValidator'),
                                    array('StringLength','min'=>4,'max'=>25),
			'filters'=>	array('StripTags'),
									array('StringTrim'),
									array('StringToLower'),
									
			'decorators'=>$this->usernameDecorators,
		)),
		
	new Zend_Form_Element_Password('userpassword', array(
			'label'=>'Пароль:',
			'required'=>'true',
            'autocomplete'=>'off',
			'size'=>'14',
		'validators'=>array('NotEmpty'),
									array('Alnum'),
                                    array('StringLength','min'=>6,'max'=>25),
			 'filters'=>array('Alnum'),
									array('StripTags'),
									array('StringTrim'),
									array('StringToLower'),
		'decorators'=>$this->elementDecorators,

		)),

		$submit = new Zend_Form_Element_Submit('submit', array(
			'label'=>'Вход',
			'class'=>'btn btn-success',
            'style'=>'margin-top:5px',
			'decorators'=>$this->buttonDecorators
		)),
		
	new Zend_Form_Element_Checkbox('checkbox', array(
		'label'=>'Запомнить меня',

		'decorators'=>$this->checkDecorators
	)),	

	$link = new Myblog_Form_Element_Link('link',array(
			'attribs'=>array('text'=>'Регистрация','title'=>'Регистрация','href'=>'/user/registration'),
			'decorators'=>$this->linkDecorators
			)),
			
	$recovery = new Myblog_Form_Element_Link('recovery',array(
			'attribs'=>array('text'=>'Забыли пароль?','title'=>'Восстановить пароль','href'=>'/user/passrecovery'),
			'decorators'=>$this->linkDecorators
			)),
	));
	$recovery->removeDecorator('Label');
	$submit->removeDecorator('Label');
	$userlogin->removeDecorator('Errors');
	$link->removeDecorator('Label');
	$link->addDecorator('HtmlTag',array('dd'=>'span','class'=>'link'));
	}
}
?>
